using System;
using System.Collections.Generic;

/// <summary>
/// Singleton class that manages a library of data for genetic stats
/// </summary>
public class GeneticStatLibrary
{
	private static GeneticStatLibrary sInstance;

	//List of all genetic stat names
	private List<string> mStatNames;

	//Dictionary mapping stat names to their associated type data
	private Dictionary<string, StatTypeData> mStatTypeDict;

	/// <summary>
	/// Gets the singleton instance of this class
	/// </summary>
	/// <value>The singleton instance.</value>
	public static GeneticStatLibrary Instance{
		get{
			if(sInstance == null){
				sInstance = new GeneticStatLibrary();
			}
			return sInstance;
		}
	}

	protected GeneticStatLibrary ()
	{
		mStatNames = new List<string>();
		mStatTypeDict = new Dictionary<string, StatTypeData>();

		SetHardCodedStats();
	}

	/// <summary>
	/// Creates a default set of genetic stats
	/// </summary>
	/// <returns>A default set of genetic stats</returns>
	public StatSet CreateGeneticStatSet(){
		StatSet retStats = new StatSet();

		//Add a value for each stat
		foreach(string statName in mStatNames){
			retStats.SetValueForStat(statName, mStatTypeDict[statName].MinValue);
		}

		return retStats;
	}

	/// <summary>
	/// Adds a new stat to the genetic stats
	/// </summary>
	/// <param name="statName">Name of the stat.</param>
	/// <param name="statData">Data describing properties of the stat.</param>
	private void AddStat(string statName, StatTypeData statData){
		mStatNames.Add (statName);
		mStatTypeDict.Add(statName, statData);
	}

	//TESTING - Create hard coded stat names
	private void SetHardCodedStats(){
		StatTypeData tempStatType = new StatTypeData();

		//Add a Strength Stat
		tempStatType.SetAll ("Strength", 0, 1000);
		AddStat(tempStatType.StatName, tempStatType);

		//Add a Vitality Stat
		tempStatType.SetAll ("Vitality", 0, 1000);
		AddStat(tempStatType.StatName, tempStatType);

		//Add a Intelligence Stat
		tempStatType.SetAll ("Agility", 0, 1000);
		AddStat(tempStatType.StatName, tempStatType);

		//Add a Strength Stat
		tempStatType.SetAll ("Speed", 0, 1000);
		AddStat(tempStatType.StatName, tempStatType);

		//Add a Strength Stat	
		tempStatType.SetAll ("Stealth", 0, 1000);
		AddStat(tempStatType.StatName, tempStatType);

		//Add a Strength Stat
		tempStatType.SetAll ("Fertility", 0, 1000);
		AddStat(tempStatType.StatName, tempStatType);

	}
	//END TESTING



}


